﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections.ObjectModel;

/// <summary>
/// Summary description for HtmlTag
/// </summary>
public class HtmlTag : HtmlAttributes, IHtmlObject
{
    private string tag;
	public HtmlTag(string newTag) : base()
	{
        tag = newTag;
	}

    public string Tag
    {
        get
        {
            return tag;
        }
        set 
        {
            tag = value;
        }
    }

    public string ToHtml()
    {
        string tempAttr="";
        foreach (string sValue in GetAttributes.Keys)
        {
            tempAttr += sValue + "=";
            foreach (string sAttr in GetAttributes[sValue])
            {
                tempAttr += sAttr + ",";
            }
            if (tempAttr[tempAttr.Length - 1] == ',')
            {
                tempAttr.Remove(tempAttr.Length - 1);
            }
        }
        return String.Format("<{0} {1}/>", tag, tempAttr);
    }
}